import * as questionApi from '@/api/hmmm/questions'
const state = {
    // 基础题库
    questionList: {},
    // 题库详情
    questionDatail: {},
    // 精选题库
    choiceQuestionList: {},
    questionFormDatail: {},
    questionRandomList: {}
}
const mutations = {
    SET_QUESTION_LIST: (state, newValue) => {
        state.questionList = newValue
    },
    SET_QUESTIONDATAIL: (state, newValue) => {
        state.questionDatail = newValue.data
    },
    SET_CHOICEQUESTION_LIST: (state, newValue) => {
        state.choiceQuestionList = newValue.data
    },
    SET_QUESTIONFORMDATAIL: (state, newValue) => {
        state.questionFormDatail = newValue.data
    },
    SET_QUESTIONRANDOM_LIST: (state, newValue) => {
      state.questionRandomList = newValue.data
    }
}
const actions = {
    async updateQuestionList({ commit }, params) {
        const res = await questionApi.list(params)
        commit('SET_QUESTION_LIST', res)
    },
    async updateQuestionDatail({ commit }, params) {
        const res = await questionApi.detail(params)
        commit('SET_QUESTIONDATAIL', res)
    },
    async updateChoiceQuestionList({ commit }, params) {
        const res = await questionApi.choice(params)
        commit('SET_CHOICEQUESTION_LIST', res)
    },
    async updateQuestionFormDatail({ commit }, params) {
        const res = await questionApi.detail(params)
        commit('SET_QUESTIONFORMDATAIL', res)
    },
    // 组题列表
    async updateQuestionRandomList({ commit }, params) {
      const res = await questionApi.randoms(params)
      commit('SET_QUESTIONRANDOM_LIST', res)
    }
}
export default {
    namespaced: true,
    state,
    mutations,
    actions
}
